/*
 * Copyright 2018 Google
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: firestore/local/mutation.proto

#include "firestore/local/mutation.pb.h"

#include <algorithm>

#include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/port.h>
#include <google/protobuf/stubs/once.h>
#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/wire_format_lite_inl.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// This is a temporary google only hack
#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
#include "third_party/protobuf/version.h"
#endif
// @@protoc_insertion_point(includes)
namespace firestore {
namespace client {
class MutationQueueDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<MutationQueue>
      _instance;
} _MutationQueue_default_instance_;
class WriteBatchDefaultTypeInternal {
 public:
  ::google::protobuf::internal::ExplicitlyConstructed<WriteBatch>
      _instance;
} _WriteBatch_default_instance_;
}  // namespace client
}  // namespace firestore
namespace protobuf_firestore_2flocal_2fmutation_2eproto {
void InitDefaultsMutationQueueImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  {
    void* ptr = &::firestore::client::_MutationQueue_default_instance_;
    new (ptr) ::firestore::client::MutationQueue();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::MutationQueue::InitAsDefaultInstance();
}

void InitDefaultsMutationQueue() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsMutationQueueImpl);
}

void InitDefaultsWriteBatchImpl() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

#ifdef GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  ::google::protobuf::internal::InitProtobufDefaultsForceUnique();
#else
  ::google::protobuf::internal::InitProtobufDefaults();
#endif  // GOOGLE_PROTOBUF_ENFORCE_UNIQUENESS
  protobuf_google_2ffirestore_2fv1beta1_2fwrite_2eproto::InitDefaultsWrite();
  protobuf_google_2fprotobuf_2ftimestamp_2eproto::InitDefaultsTimestamp();
  {
    void* ptr = &::firestore::client::_WriteBatch_default_instance_;
    new (ptr) ::firestore::client::WriteBatch();
    ::google::protobuf::internal::OnShutdownDestroyMessage(ptr);
  }
  ::firestore::client::WriteBatch::InitAsDefaultInstance();
}

void InitDefaultsWriteBatch() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &InitDefaultsWriteBatchImpl);
}

::google::protobuf::Metadata file_level_metadata[2];

const ::google::protobuf::uint32 TableStruct::offsets[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MutationQueue, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MutationQueue, last_acknowledged_batch_id_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::MutationQueue, last_stream_token_),
  ~0u,  // no _has_bits_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::WriteBatch, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::WriteBatch, batch_id_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::WriteBatch, writes_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::WriteBatch, local_write_time_),
  GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(::firestore::client::WriteBatch, base_writes_),
};
static const ::google::protobuf::internal::MigrationSchema schemas[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
  { 0, -1, sizeof(::firestore::client::MutationQueue)},
  { 7, -1, sizeof(::firestore::client::WriteBatch)},
};

static ::google::protobuf::Message const * const file_default_instances[] = {
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_MutationQueue_default_instance_),
  reinterpret_cast<const ::google::protobuf::Message*>(&::firestore::client::_WriteBatch_default_instance_),
};

void protobuf_AssignDescriptors() {
  AddDescriptors();
  ::google::protobuf::MessageFactory* factory = NULL;
  AssignDescriptors(
      "firestore/local/mutation.proto", schemas, file_default_instances, TableStruct::offsets, factory,
      file_level_metadata, NULL, NULL);
}

void protobuf_AssignDescriptorsOnce() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &protobuf_AssignDescriptors);
}

void protobuf_RegisterTypes(const ::std::string&) GOOGLE_PROTOBUF_ATTRIBUTE_COLD;
void protobuf_RegisterTypes(const ::std::string&) {
  protobuf_AssignDescriptorsOnce();
  ::google::protobuf::internal::RegisterAllTypes(file_level_metadata, 2);
}

void AddDescriptorsImpl() {
  InitDefaults();
  static const char descriptor[] GOOGLE_PROTOBUF_ATTRIBUTE_SECTION_VARIABLE(protodesc_cold) = {
      "\n\036firestore/local/mutation.proto\022\020firest"
      "ore.client\032$google/firestore/v1beta1/wri"
      "te.proto\032\037google/protobuf/timestamp.prot"
      "o\"N\n\rMutationQueue\022\"\n\032last_acknowledged_"
      "batch_id\030\001 \001(\005\022\031\n\021last_stream_token\030\002 \001("
      "\014\"\273\001\n\nWriteBatch\022\020\n\010batch_id\030\001 \001(\005\022/\n\006wr"
      "ites\030\002 \003(\0132\037.google.firestore.v1beta1.Wr"
      "ite\0224\n\020local_write_time\030\003 \001(\0132\032.google.p"
      "rotobuf.Timestamp\0224\n\013base_writes\030\004 \003(\0132\037"
      ".google.firestore.v1beta1.WriteB/\n#com.g"
      "oogle.firebase.firestore.protoP\001\242\002\005FSTPB"
      "b\006proto3"
  };
  ::google::protobuf::DescriptorPool::InternalAddGeneratedFile(
      descriptor, 448);
  ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
    "firestore/local/mutation.proto", &protobuf_RegisterTypes);
  ::protobuf_google_2ffirestore_2fv1beta1_2fwrite_2eproto::AddDescriptors();
  ::protobuf_google_2fprotobuf_2ftimestamp_2eproto::AddDescriptors();
}

void AddDescriptors() {
  static GOOGLE_PROTOBUF_DECLARE_ONCE(once);
  ::google::protobuf::GoogleOnceInit(&once, &AddDescriptorsImpl);
}
// Force AddDescriptors() to be called at dynamic initialization time.
struct StaticDescriptorInitializer {
  StaticDescriptorInitializer() {
    AddDescriptors();
  }
} static_descriptor_initializer;
}  // namespace protobuf_firestore_2flocal_2fmutation_2eproto
namespace firestore {
namespace client {

// ===================================================================

void MutationQueue::InitAsDefaultInstance() {
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int MutationQueue::kLastAcknowledgedBatchIdFieldNumber;
const int MutationQueue::kLastStreamTokenFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

MutationQueue::MutationQueue()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2fmutation_2eproto::InitDefaultsMutationQueue();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.MutationQueue)
}
MutationQueue::MutationQueue(const MutationQueue& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  last_stream_token_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  if (from.last_stream_token().size() > 0) {
    last_stream_token_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.last_stream_token_);
  }
  last_acknowledged_batch_id_ = from.last_acknowledged_batch_id_;
  // @@protoc_insertion_point(copy_constructor:firestore.client.MutationQueue)
}

void MutationQueue::SharedCtor() {
  last_stream_token_.UnsafeSetDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  last_acknowledged_batch_id_ = 0;
  _cached_size_ = 0;
}

MutationQueue::~MutationQueue() {
  // @@protoc_insertion_point(destructor:firestore.client.MutationQueue)
  SharedDtor();
}

void MutationQueue::SharedDtor() {
  last_stream_token_.DestroyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
}

void MutationQueue::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* MutationQueue::descriptor() {
  ::protobuf_firestore_2flocal_2fmutation_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmutation_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const MutationQueue& MutationQueue::default_instance() {
  ::protobuf_firestore_2flocal_2fmutation_2eproto::InitDefaultsMutationQueue();
  return *internal_default_instance();
}

MutationQueue* MutationQueue::New(::google::protobuf::Arena* arena) const {
  MutationQueue* n = new MutationQueue;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void MutationQueue::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.MutationQueue)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  last_stream_token_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
  last_acknowledged_batch_id_ = 0;
  _internal_metadata_.Clear();
}

bool MutationQueue::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.MutationQueue)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // int32 last_acknowledged_batch_id = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &last_acknowledged_batch_id_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // bytes last_stream_token = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadBytes(
                input, this->mutable_last_stream_token()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.MutationQueue)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.MutationQueue)
  return false;
#undef DO_
}

void MutationQueue::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.MutationQueue)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 last_acknowledged_batch_id = 1;
  if (this->last_acknowledged_batch_id() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->last_acknowledged_batch_id(), output);
  }

  // bytes last_stream_token = 2;
  if (this->last_stream_token().size() > 0) {
    ::google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(
      2, this->last_stream_token(), output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.MutationQueue)
}

::google::protobuf::uint8* MutationQueue::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.MutationQueue)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 last_acknowledged_batch_id = 1;
  if (this->last_acknowledged_batch_id() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->last_acknowledged_batch_id(), target);
  }

  // bytes last_stream_token = 2;
  if (this->last_stream_token().size() > 0) {
    target =
      ::google::protobuf::internal::WireFormatLite::WriteBytesToArray(
        2, this->last_stream_token(), target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.MutationQueue)
  return target;
}

size_t MutationQueue::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.MutationQueue)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // bytes last_stream_token = 2;
  if (this->last_stream_token().size() > 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::BytesSize(
        this->last_stream_token());
  }

  // int32 last_acknowledged_batch_id = 1;
  if (this->last_acknowledged_batch_id() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->last_acknowledged_batch_id());
  }

  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void MutationQueue::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.MutationQueue)
  GOOGLE_DCHECK_NE(&from, this);
  const MutationQueue* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const MutationQueue>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.MutationQueue)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.MutationQueue)
    MergeFrom(*source);
  }
}

void MutationQueue::MergeFrom(const MutationQueue& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.MutationQueue)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  if (from.last_stream_token().size() > 0) {

    last_stream_token_.AssignWithDefault(&::google::protobuf::internal::GetEmptyStringAlreadyInited(), from.last_stream_token_);
  }
  if (from.last_acknowledged_batch_id() != 0) {
    set_last_acknowledged_batch_id(from.last_acknowledged_batch_id());
  }
}

void MutationQueue::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.MutationQueue)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MutationQueue::CopyFrom(const MutationQueue& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.MutationQueue)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MutationQueue::IsInitialized() const {
  return true;
}

void MutationQueue::Swap(MutationQueue* other) {
  if (other == this) return;
  InternalSwap(other);
}
void MutationQueue::InternalSwap(MutationQueue* other) {
  using std::swap;
  last_stream_token_.Swap(&other->last_stream_token_);
  swap(last_acknowledged_batch_id_, other->last_acknowledged_batch_id_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata MutationQueue::GetMetadata() const {
  protobuf_firestore_2flocal_2fmutation_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmutation_2eproto::file_level_metadata[kIndexInFileMessages];
}


// ===================================================================

void WriteBatch::InitAsDefaultInstance() {
  ::firestore::client::_WriteBatch_default_instance_._instance.get_mutable()->local_write_time_ = const_cast< ::google::protobuf::Timestamp*>(
      ::google::protobuf::Timestamp::internal_default_instance());
}
void WriteBatch::clear_writes() {
  writes_.Clear();
}
void WriteBatch::clear_local_write_time() {
  if (GetArenaNoVirtual() == NULL && local_write_time_ != NULL) {
    delete local_write_time_;
  }
  local_write_time_ = NULL;
}
void WriteBatch::clear_base_writes() {
  base_writes_.Clear();
}
#if !defined(_MSC_VER) || _MSC_VER >= 1900
const int WriteBatch::kBatchIdFieldNumber;
const int WriteBatch::kWritesFieldNumber;
const int WriteBatch::kLocalWriteTimeFieldNumber;
const int WriteBatch::kBaseWritesFieldNumber;
#endif  // !defined(_MSC_VER) || _MSC_VER >= 1900

WriteBatch::WriteBatch()
  : ::google::protobuf::Message(), _internal_metadata_(NULL) {
  if (GOOGLE_PREDICT_TRUE(this != internal_default_instance())) {
    ::protobuf_firestore_2flocal_2fmutation_2eproto::InitDefaultsWriteBatch();
  }
  SharedCtor();
  // @@protoc_insertion_point(constructor:firestore.client.WriteBatch)
}
WriteBatch::WriteBatch(const WriteBatch& from)
  : ::google::protobuf::Message(),
      _internal_metadata_(NULL),
      writes_(from.writes_),
      base_writes_(from.base_writes_),
      _cached_size_(0) {
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  if (from.has_local_write_time()) {
    local_write_time_ = new ::google::protobuf::Timestamp(*from.local_write_time_);
  } else {
    local_write_time_ = NULL;
  }
  batch_id_ = from.batch_id_;
  // @@protoc_insertion_point(copy_constructor:firestore.client.WriteBatch)
}

void WriteBatch::SharedCtor() {
  ::memset(&local_write_time_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&batch_id_) -
      reinterpret_cast<char*>(&local_write_time_)) + sizeof(batch_id_));
  _cached_size_ = 0;
}

WriteBatch::~WriteBatch() {
  // @@protoc_insertion_point(destructor:firestore.client.WriteBatch)
  SharedDtor();
}

void WriteBatch::SharedDtor() {
  if (this != internal_default_instance()) delete local_write_time_;
}

void WriteBatch::SetCachedSize(int size) const {
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
}
const ::google::protobuf::Descriptor* WriteBatch::descriptor() {
  ::protobuf_firestore_2flocal_2fmutation_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmutation_2eproto::file_level_metadata[kIndexInFileMessages].descriptor;
}

const WriteBatch& WriteBatch::default_instance() {
  ::protobuf_firestore_2flocal_2fmutation_2eproto::InitDefaultsWriteBatch();
  return *internal_default_instance();
}

WriteBatch* WriteBatch::New(::google::protobuf::Arena* arena) const {
  WriteBatch* n = new WriteBatch;
  if (arena != NULL) {
    arena->Own(n);
  }
  return n;
}

void WriteBatch::Clear() {
// @@protoc_insertion_point(message_clear_start:firestore.client.WriteBatch)
  ::google::protobuf::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  writes_.Clear();
  base_writes_.Clear();
  if (GetArenaNoVirtual() == NULL && local_write_time_ != NULL) {
    delete local_write_time_;
  }
  local_write_time_ = NULL;
  batch_id_ = 0;
  _internal_metadata_.Clear();
}

bool WriteBatch::MergePartialFromCodedStream(
    ::google::protobuf::io::CodedInputStream* input) {
#define DO_(EXPRESSION) if (!GOOGLE_PREDICT_TRUE(EXPRESSION)) goto failure
  ::google::protobuf::uint32 tag;
  // @@protoc_insertion_point(parse_start:firestore.client.WriteBatch)
  for (;;) {
    ::std::pair< ::google::protobuf::uint32, bool> p = input->ReadTagWithCutoffNoLastTag(127u);
    tag = p.first;
    if (!p.second) goto handle_unusual;
    switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) {
      // int32 batch_id = 1;
      case 1: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(8u /* 8 & 0xFF */)) {

          DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
                   ::google::protobuf::int32, ::google::protobuf::internal::WireFormatLite::TYPE_INT32>(
                 input, &batch_id_)));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // repeated .google.firestore.v1beta1.Write writes = 2;
      case 2: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(18u /* 18 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_writes()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // .google.protobuf.Timestamp local_write_time = 3;
      case 3: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(26u /* 26 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(
               input, mutable_local_write_time()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      // repeated .google.firestore.v1beta1.Write base_writes = 4;
      case 4: {
        if (static_cast< ::google::protobuf::uint8>(tag) ==
            static_cast< ::google::protobuf::uint8>(34u /* 34 & 0xFF */)) {
          DO_(::google::protobuf::internal::WireFormatLite::ReadMessage(input, add_base_writes()));
        } else {
          goto handle_unusual;
        }
        break;
      }

      default: {
      handle_unusual:
        if (tag == 0) {
          goto success;
        }
        DO_(::google::protobuf::internal::WireFormat::SkipField(
              input, tag, _internal_metadata_.mutable_unknown_fields()));
        break;
      }
    }
  }
success:
  // @@protoc_insertion_point(parse_success:firestore.client.WriteBatch)
  return true;
failure:
  // @@protoc_insertion_point(parse_failure:firestore.client.WriteBatch)
  return false;
#undef DO_
}

void WriteBatch::SerializeWithCachedSizes(
    ::google::protobuf::io::CodedOutputStream* output) const {
  // @@protoc_insertion_point(serialize_start:firestore.client.WriteBatch)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 batch_id = 1;
  if (this->batch_id() != 0) {
    ::google::protobuf::internal::WireFormatLite::WriteInt32(1, this->batch_id(), output);
  }

  // repeated .google.firestore.v1beta1.Write writes = 2;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->writes_size()); i < n; i++) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      2, this->writes(static_cast<int>(i)), output);
  }

  // .google.protobuf.Timestamp local_write_time = 3;
  if (this->has_local_write_time()) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      3, *this->local_write_time_, output);
  }

  // repeated .google.firestore.v1beta1.Write base_writes = 4;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->base_writes_size()); i < n; i++) {
    ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(
      4, this->base_writes(static_cast<int>(i)), output);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    ::google::protobuf::internal::WireFormat::SerializeUnknownFields(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), output);
  }
  // @@protoc_insertion_point(serialize_end:firestore.client.WriteBatch)
}

::google::protobuf::uint8* WriteBatch::InternalSerializeWithCachedSizesToArray(
    bool deterministic, ::google::protobuf::uint8* target) const {
  (void)deterministic; // Unused
  // @@protoc_insertion_point(serialize_to_array_start:firestore.client.WriteBatch)
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // int32 batch_id = 1;
  if (this->batch_id() != 0) {
    target = ::google::protobuf::internal::WireFormatLite::WriteInt32ToArray(1, this->batch_id(), target);
  }

  // repeated .google.firestore.v1beta1.Write writes = 2;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->writes_size()); i < n; i++) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        2, this->writes(static_cast<int>(i)), deterministic, target);
  }

  // .google.protobuf.Timestamp local_write_time = 3;
  if (this->has_local_write_time()) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        3, *this->local_write_time_, deterministic, target);
  }

  // repeated .google.firestore.v1beta1.Write base_writes = 4;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->base_writes_size()); i < n; i++) {
    target = ::google::protobuf::internal::WireFormatLite::
      InternalWriteMessageToArray(
        4, this->base_writes(static_cast<int>(i)), deterministic, target);
  }

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()), target);
  }
  // @@protoc_insertion_point(serialize_to_array_end:firestore.client.WriteBatch)
  return target;
}

size_t WriteBatch::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:firestore.client.WriteBatch)
  size_t total_size = 0;

  if ((_internal_metadata_.have_unknown_fields() &&  ::google::protobuf::internal::GetProto3PreserveUnknownsDefault())) {
    total_size +=
      ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
        (::google::protobuf::internal::GetProto3PreserveUnknownsDefault()   ? _internal_metadata_.unknown_fields()   : _internal_metadata_.default_instance()));
  }
  // repeated .google.firestore.v1beta1.Write writes = 2;
  {
    unsigned int count = static_cast<unsigned int>(this->writes_size());
    total_size += 1UL * count;
    for (unsigned int i = 0; i < count; i++) {
      total_size +=
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          this->writes(static_cast<int>(i)));
    }
  }

  // repeated .google.firestore.v1beta1.Write base_writes = 4;
  {
    unsigned int count = static_cast<unsigned int>(this->base_writes_size());
    total_size += 1UL * count;
    for (unsigned int i = 0; i < count; i++) {
      total_size +=
        ::google::protobuf::internal::WireFormatLite::MessageSize(
          this->base_writes(static_cast<int>(i)));
    }
  }

  // .google.protobuf.Timestamp local_write_time = 3;
  if (this->has_local_write_time()) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::MessageSize(
        *this->local_write_time_);
  }

  // int32 batch_id = 1;
  if (this->batch_id() != 0) {
    total_size += 1 +
      ::google::protobuf::internal::WireFormatLite::Int32Size(
        this->batch_id());
  }

  int cached_size = ::google::protobuf::internal::ToCachedSize(total_size);
  GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
  _cached_size_ = cached_size;
  GOOGLE_SAFE_CONCURRENT_WRITES_END();
  return total_size;
}

void WriteBatch::MergeFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:firestore.client.WriteBatch)
  GOOGLE_DCHECK_NE(&from, this);
  const WriteBatch* source =
      ::google::protobuf::internal::DynamicCastToGenerated<const WriteBatch>(
          &from);
  if (source == NULL) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:firestore.client.WriteBatch)
    ::google::protobuf::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:firestore.client.WriteBatch)
    MergeFrom(*source);
  }
}

void WriteBatch::MergeFrom(const WriteBatch& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:firestore.client.WriteBatch)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom(from._internal_metadata_);
  ::google::protobuf::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  writes_.MergeFrom(from.writes_);
  base_writes_.MergeFrom(from.base_writes_);
  if (from.has_local_write_time()) {
    mutable_local_write_time()->::google::protobuf::Timestamp::MergeFrom(from.local_write_time());
  }
  if (from.batch_id() != 0) {
    set_batch_id(from.batch_id());
  }
}

void WriteBatch::CopyFrom(const ::google::protobuf::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:firestore.client.WriteBatch)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void WriteBatch::CopyFrom(const WriteBatch& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:firestore.client.WriteBatch)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool WriteBatch::IsInitialized() const {
  return true;
}

void WriteBatch::Swap(WriteBatch* other) {
  if (other == this) return;
  InternalSwap(other);
}
void WriteBatch::InternalSwap(WriteBatch* other) {
  using std::swap;
  writes_.InternalSwap(&other->writes_);
  base_writes_.InternalSwap(&other->base_writes_);
  swap(local_write_time_, other->local_write_time_);
  swap(batch_id_, other->batch_id_);
  _internal_metadata_.Swap(&other->_internal_metadata_);
  swap(_cached_size_, other->_cached_size_);
}

::google::protobuf::Metadata WriteBatch::GetMetadata() const {
  protobuf_firestore_2flocal_2fmutation_2eproto::protobuf_AssignDescriptorsOnce();
  return ::protobuf_firestore_2flocal_2fmutation_2eproto::file_level_metadata[kIndexInFileMessages];
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace client
}  // namespace firestore

// @@protoc_insertion_point(global_scope)
